{extend name="user-layout" /}
{block name="content"}
<div class="content-wrapper">
    <div class="row">
        {include file="balance/info"}
        <div class="col-md-8 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">提现管理</h4>
                    <p class="card-description text-danger">注： 一天仅允许提现一次哟！</p>
                    <ul class="nav nav-tabs tab-basic" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="apply-tab" data-toggle="tab" href="#apply" role="tab" aria-controls="apply" aria-selected="true"><i class="icon-wallet"></i>申请提现</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="set-tab" data-toggle="tab" href="#set" role="tab" aria-controls="set" aria-selected="false"><i class="icon-settings"></i>提现设置</a>
                        </li>
                    </ul>
                    <div class="tab-content tab-content-basic">
                        <div class="tab-pane fade show active" id="apply" role="tabpanel" aria-labelledby="apply-tab">
                            <form class="layui-form forms-sample" action="" method="post">
                                <input name="b[uid]" value="{$info.uid}" hidden disabled readonly>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">可提金额</label>
                                    <div class="col-sm-9">
                                        <input type="text" value="{$info.enable}" class="form-control" id="enable" readonly>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="amount" class="col-sm-2 col-form-label">提现金额</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="b[amount]" value="" required lay-verify="required|vernum" class="form-control" minlength="2" maxlength="6" id="amount" placeholder="提现金额">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">手续费</label>
                                    <div class="col-sm-9">
                                        <input type="text" name="b[fee]" id="fee" class="form-control" placeholder="输入提现金额自动计算" readonly>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">收款账户</label>
                                    <div class="col-sm-9">
                                        <select name="b[account]" required lay-verify="required" class="form-control">
                                            <option value="">选择收款账户</option>
                                            {volist name="list" id="vo"}
                                            <option value="{$vo.id}">{$vo.banker}({:substr_replace($vo['account'],"****",3,4)})</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">手机验证码</label>
                                    <div class="col-sm-9">
                                        <div class="input-group col-xs-12">
                                            <input type="text" name="b[vercode]" required lay-verify="required" maxlength="6" class="form-control file-upload-info" placeholder="手机验证码">
                                            <span class="input-group-append">
                                                <button type="button" id="sendVerCode" class="file-upload-browse btn-show-vercode btn btn-primary">发送</button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">备注</label>
                                    <div class="col-sm-9">
                                        <textarea type="text" name="b[remarks]" class="form-control" rows="3">自助提现，<?php echo date('Ymdhis');?>验证通过</textarea>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label"></label>
                                    <div class="col-sm-9">
                                        <button type="button" class="btn btn-primary btn-submit-balance-apply btn-fw" lay-submit lay-filter="app-balance-apply-submit">提交申请</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="tab-pane fade" id="set" role="tabpanel" aria-labelledby="set-tab">
                            <form class="layui-form forms-sample" action="" method="post">
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">提现方式</label>
                                    <div class="col-sm-9">
                                        <select name="type" required lay-verify="required" class="form-control">
                                            <option selected value="auto">自动提现（每日自动打款）</option>
                                            <option value="hander">手动提现（随时随地，自主申请提现）</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label">默认账号</label>
                                    <div class="col-sm-9">
                                        <select name="account" required lay-verify="required" class="form-control">
                                            <option value="">选择收款账户</option>
                                            {volist name="list" id="vo"}
                                            <option value="{$vo.id}">{$vo.banker}({:substr_replace($vo['account'],"****",3,4)})</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="amount" class="col-sm-2 col-form-label">提现时间</label>
                                    <div class="col-sm-9">
                                        <div class="input-group date" id="timepicker-balance-set" data-target-input="nearest">
                                            <div class="input-group" data-target="#timepicker-balance-set" data-toggle="datetimepicker">
                                                <input type="text" name="date" required lay-verify="required"  class="form-control datetimepicker-input" data-target="#timepicker-balance-set">
                                                <div class="input-group-addon input-group-append"><i class="icon-clock input-group-text"></i></div>
                                            </div>
                                            <p class="text-warning">注： 仅在自动打款时有效</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 col-form-label"></label>
                                    <div class="col-sm-9">
                                        <button type="button" class="btn btn-primary btn-submit-balance-set btn-fw" lay-submit lay-filter="app-balance-apply-set">提交申请</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagejs"}

<script src="__STATIC__/cloudui/js/formpickers.js"></script>
<script>
    layui.use(['form'], function(){
        let $ = layui.$
            ,form = layui.form; // 验证码限制时间

        //监听提现计算
        $('#amount').bind('input propertychange', function() {
            let amount = $('#amount').val();

            $('#fee').val(amount*(2/1000));
        });

        //数据验证
        form.verify({
            vernum: function(v) {
                if (v * 100 > $("#enable").val()* 100) return "提现金额大于可用金额！";
                if ( 100 > v * 10) return "满10元才可提现哟！";
            }
        });

        //监听提现提交
        form.on('submit(app-balance-apply-submit)', function(data){
            let field = data.field;
            console.log(field);
            //提交
            $.ajax({
                url:'{:url(\'index/Balance/apply\')}',
                method:"POST",
                data:field, success:function (res) {
                    if (res.code == 1){setTimeout("location.reload();",1500);}
                    showToast(res);
                }
            });
        });

        //监听设置提交
        form.on('submit(app-balance-apply-set)', function(data){
            let field = data.field;
            console.log(field);
            let obj = new Object();
                obj.code = 2;
                obj.msg = '等待开发...';
            showToast(obj);
        });
    });
</script>
{/block}
